import { createRouter, createWebHashHistory } from "vue-router";
import Home from "../views/home/index.vue";
import NotFound from "../views/NotFound.vue";
import BlogDetail from "@/views/components/blog-detail.vue";

const routes = [
  {
    name: "home",
    path: "/home",
    meta: {
      title: "首页",
      keepAlive: true,
    },
    component: Home,
  },
  {
    name: "programmer",
    path: "/programmer",
    meta: {
      title: "语言",
      keepAlive: false,
    },
    component: () => import("@/views/Programmer/index.vue"),
    children: [
      {
        name: "pageWeb",
        path: "pageWeb",
        meta: {
          title: "web",
          keepAlive: false,
        },
        component: () => import("@/views/Programmer/PageWeb.vue"),
      },
      {
        name: "pageNode",
        path: "pageNode",
        meta: {
          title: "node",
          keepAlive: false,
        },
        component: () => import("@/views/Programmer/PageNode.vue"),
      },
    ],
  },
  {
    name: "bookThinks",
    path: "/bookThinks",
    meta: {
      title: "读书感悟",
      keepAlive: false,
    },
    component: () => import("@/views/bookThinks.vue"),
  },
  {
    name: "lives",
    path: "/lives",
    meta: {
      title: "生活琐碎",
      keepAlive: false,
    },
    component: () => import("@/views/lives.vue"),
  },
  {
    name: "times",
    path: "/times",
    meta: {
      title: "时间轴",
      keepAlive: true,
    },
    component: () => import("@/views/times.vue"),
  },
  {
    name: "about",
    path: "/about",
    meta: {
      title: "关于",
      keepAlive: true,
    },
    component: () => import("@/views/about.vue"),
  },
  {
    name: "detail",
    path: "/detai",
    meta: {
      title: "详情",
      keepAlive: false,
    },
    component: BlogDetail,
  },
  // {
  //   name: "detail-md",
  //   path: "/detail-md/:_id",
  //   meta: {
  //     title: "详情",
  //     keepAlive: false,
  //   },
  //   component: () => import("@/views/components/blog-detail-md.vue"),
  // },
  {
    path: "/",
    redirect: {
      name: "home",
    },
  },
  {
    name: "notFound",
    path: "/404",
    component: NotFound,
  },
  {
    path: "/:pathMatch(.*)*",
    redirect: "/404",
  },
  // {
  //   path: "/about",
  //   name: "About",
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () =>
  //     import(/* webpackChunkName: "about" */ "../views/About.vue"),
  // },
];

export { routes };

const router = createRouter({
  history: createWebHashHistory("/ILog"),
  routes,
});

export default router;
